﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Ras2Logic;

namespace Ras2Web
{
    /// <summary>
    /// Klasinn SongDetail
    /// </summary>
    public partial class SongDetail : System.Web.UI.Page
    {
        /// <summary>
        /// Fall sem nær í tiltekið lag í gagnagrunninum og sýnir
        /// nánari upplýsingar um það, þ.e. nafn, flytjanda, slóð á MP3 
        /// og nánari lýsingu sé hún fyrir hendi.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                String strID = Request.QueryString["ID"];
                int nID = 0;

                if (Int32.TryParse(strID, out nID))
                {
                    this.ViewState["SongID"] = strID;

                    SongController ctrl = new SongController();
                    Song song = ctrl.GetSongById(nID);
                    
                    if (song != null)
                    {
                        PerformerController p_ctrl = new PerformerController();
                        Performer performer = p_ctrl.GetPerformerById(Convert.ToInt32(song.PerformerID));
                        m_txtName.Text = song.Name;
                        m_txtPerformer.Text = performer.Name;
                        m_txtMP3.Text = song.MP3Path;
                        m_txtDescription.Text = song.Description;
                    }
                }
            }
        }
    }
}
